package ThreadState;

/**
 * @author 王艺锡
 * @version 1.0
 */
public class ThreadState {
    public static void main(String[] args) throws InterruptedException {
        T t = new T();
        System.out.println(t.getName() + "状态" + t.getState());
        t.start();
        System.out.println(t.getName() + "状态" + t.getState());
        while (Thread.State.TERMINATED != t.getState()){
            System.out.println(t.getName() + "状态" + t.getState());
            Thread.sleep(500);
        }
        System.out.println(t.getName() + "状态" + t.getState());
    }
}
class T extends Thread{
    private int count = 0;
    @Override
    public void run() {
        while (count < 10){
            System.out.println("hi" + (++count));
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
